'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
     await queryInterface.createTable('cookbook', { 
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER,
        comment: 'id'
      },
      name: {
        type: Sequelize.STRING(100),
        allowNull: false,
        defaultValue: '',
        comment: '名称'
      },
      user_id: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: '发表人id'
      },
      category_id: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: '分类id'
      },
      description: {
        type: Sequelize.CHAR(200),
        allowNull: false,
        defaultValue: '',
        comment: '简介'
      },
      cover: {
        type: Sequelize.STRING(50),
        allowNull: false,
        defaultValue: '',
        comment: '封面'
      },
      craft_id: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: '食材id'
      },
      level_id: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: '工艺id'
      },
      taste_id: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: '分类id'
      },
      need_time: {
        allowNull: false,
        type: Sequelize.DATE,
        filed: 'need_at',
        comment: '所需要的时间'
      },
      ingredients: {
        type: Sequelize.STRING(50),
        allowNull: false,
        defaultValue: '',
        comment: '成分'
      },
      created_at: {
        allowNull: false,
        type: Sequelize.DATE,
        filed: 'created_at',
        comment: '创建时间'
      },
      updated_at: {
        allowNull: false,
        type: Sequelize.DATE,
        filed: 'updated_at',
        comment: '更新的时间'
      }
      }, {
        tableName: 'cookbook',
        charset: 'utf8mb4',
        collate: 'utf8mb4_bin',
        indexes: [
          {

          }
        ]
    });    
  },

  down: async (queryInterface, Sequelize) => {
     await queryInterface.dropTable('cookbook');
  }
};
